import { handleSearchLoading } from "@userList/search";
import { roleDict, signStatusDict } from "@/views/society/party/dict";
import { IMOptionsType } from "@/types/dict";
const searchLoading = ref(false);
const resetLoading = ref(false);
export const userSexMap: Array<IMOptionsType> = [
  {
    value: 1,
    label: getProxyT("dict9"),
  },
  {
    value: 2,
    label: getProxyT("dict10"),
  },
  {
    value: 3,
    label: getProxyT("dict11"),
  },
];
export const searchConfig = ({
  handleAction,
  refreshTable = (arg: any) => {},
}: any) => {
  const defineSearch = {
    okText: getProxyT("base.query"),
    cancelText: getProxyT("base.reset"),
    searchLoading,
    resetLoading,
    refreshTableData: async (searchParams: any, type: any) => {
      searchParams.status =
        searchParams.status === "" ? undefined : searchParams.status;
      handleSearchLoading(true, type, defineSearch);
      await refreshTable(searchParams);
      handleSearchLoading(false, type, defineSearch);
    },
    searchList: [
      {
        label: getProxyT("party39"),
        type: "input",
        model: "initiator",
        allowClear: true,
        placeholder: getProxyT("party45"),
      },
      {
        label: getProxyT("party40"),
        type: "select",
        model: "gender",
        placeholder: getProxyT("party46"),
        searchClass: "search-item-width-150",
        allowClear: true,
        options: userSexMap,
      },
      {
        label: getProxyT("party41"),
        type: "select",
        model: "role",
        placeholder: getProxyT("party46"),
        searchClass: "search-item-width-150",
        allowClear: true,
        options: roleDict,
      },
      {
        label: getProxyT("party42"),
        type: "rangePicker",
        model: "join_start_end",
        placeholder: computed(() => [$t("base.startTime"), $t("base.endTime")]),
      },
      {
        label: getProxyT("party43"),
        type: "select",
        model: "sign_status",
        placeholder: getProxyT("party46"),
        searchClass: "search-item-width-150",
        allowClear: true,
        options: signStatusDict,
      },
      {
        label: getProxyT("party44"),
        type: "rangePicker",
        model: "signed_start_end",
        placeholder: computed(() => [$t("base.startTime"), $t("base.endTime")]),
      },
    ],
  };
  return defineSearch;
};
